package com.denlaku.longan.service.impl;

import com.denlaku.longan.anno.RequiredTx;
import com.denlaku.longan.repository.CustomApiFieldRepository;
import com.denlaku.longan.service.CustomApiFieldService;
import com.denlaku.longan.vo.CustomApiField;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author tianx
 */
@Service
public class CustomApiFieldServiceImpl implements CustomApiFieldService {
    @Autowired
    private CustomApiFieldRepository customApiFieldRepository;

    @Override
    @RequiredTx
    public void batchAdd(List<CustomApiField> fields) {
        if (CollectionUtils.isNotEmpty(fields)) {
            customApiFieldRepository.batchAdd(fields);
        }
    }

    @Override
    public List<CustomApiField> list(Long tenantId, Long apiId) {
        return customApiFieldRepository.list(tenantId, apiId);
    }

    @Override
    public void delete(Long tenantId, Long apiId) {
        customApiFieldRepository.delete(tenantId, apiId);
    }

}
